# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: JJDaNiMoTh <jjdanimoth.aur@gmail.com>
# Contributor: zlowly <zlowly [at] archlinux.org>

pkgname=wqy-zenhei
pkgver=0.9.45
pkgrel=9
pkgdesc="A Hei Ti Style (sans-serif) Chinese Outline Font."
arch=('any')
license=('GPL2' 'custom:"font embedding exception"')
install=wqy-zenhei.install
url="https://wenq.org/enindex.cgi"
depends=(sh)
source=("https://downloads.sourceforge.net/project/wqy/wqy-zenhei/$pkgver%20%28Fighting-state%20RC1%29/wqy-zenhei-$pkgver.tar.gz"
	"44-wqy-zenhei.conf.diff")
md5sums=('4c6c3f4e902dd5ee0a121e8c41d040bd'
         '1cdbb5dd5ea90faf48cf1ba61077da15')
b2sums=('00cb4c4f3c6d76f8d81192407813940634c634288a8945fbad0c74642759102d484db875ad5c5be0462ecb4a87c1038893a578c669a70aca80071ebb12c7b154'
        '2390db80db8d8f95b0d893c0533c9d05be6f164800e6eb22399f899c671dcfabc7803f5c11228beb57981fc4a4a89ebb93a71f8c4b21068e261e62173b1d5cf8')

prepare() {
  cd "$srcdir"/$pkgname

  patch -p0 44-wqy-zenhei.conf <"$srcdir"/44-wqy-zenhei.conf.diff

  grep README -e "GPL v2 license with font embedding exception" -A 12 >| FONTEXCEPTION

  # https://bugs.archlinux.org/task/24177
  mv 44-wqy-zenhei.conf 65-wqy-zenhei.conf
}

package() {
  cd "$srcdir"/$pkgname

  install -Dm644 FONTEXCEPTION -t "$pkgdir"/usr/share/licenses/$pkgname
  install -Dm644 *.ttc -t "$pkgdir"/usr/share/fonts/wenquanyi/wqy-zenhei
  install -Dm644 *.conf -t "$pkgdir"/usr/share/fontconfig/conf.avail
  install -Dm755 zenheiset -t "$pkgdir"/usr/bin
  install -d "$pkgdir"/usr/share/fontconfig/conf.default
  ln -s ../conf.avail/65-wqy-zenhei.conf -t "$pkgdir"/usr/share/fontconfig/conf.default
  # ln -s ../conf.avail/43-wqy-zenhei-sharp.conf -t "$pkgdir"/usr/share/fontconfig/conf.default
}
